package com.itcast.mallweb.service.impl;

import com.itcast.admin.dto.OrderDTO;
import com.itcast.admin.vo.DityVO;
import com.itcast.admin.vo.OrderAllVO;
import com.itcast.applet.entity.Order;
import com.itcast.context.BaseContext;
import com.itcast.mallweb.mapper.OrderMapper;
import com.itcast.mallweb.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Service
@Slf4j
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    //查询全部订单
    public List<OrderAllVO> orderQueryAll() {
        List<Order> orders = orderMapper.orderQueryAll();
        List<Long> longList = orders.stream()
                .map(Order::getId)
                .collect(Collectors.toList());
        List<OrderAllVO> orderAllVO = orderMapper.orderAllQuery(longList);
        return orderAllVO;
    }

    //修改订单状态
    public void orderAmend(OrderDTO orderDTO) {
        orderMapper.orderAmendStatus(orderDTO);
    }
}
